<?php

/**
 * This is the model class for table "establishment".
 *
 * The followings are the available columns in table 'establishment':
 * @property integer $id
 * @property string $type_of_establishment
 * @property string $establishment_name
 * @property string $building_owner
 * @property string $address_street
 * @property string $baranggay
 *
 * The followings are the available model relations:
 * @property ClientContactPerson[] $clientContactPeople
 * @property Inspection[] $inspections
 */
class Establishment extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Establishment the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
const a ="Business";
const b ="Educational";
const c ="Gasoline";
const d ="HeathCare";
const e ="Industrial";
const f ="Merchatile";
const g ="Miscellaneous";
const h ="Place of Assembly";
const i ="Residencial";
const j ="Small/General Business";
const k ="Storage";
public function getType_of_establishment(){
return array(
self::a=>"Business",
self::b=>"Educational",
self::c=>"Gasoline",
self::d=>"HeathCare",
self::e=>"Industrial",
self::f=>"Merchatile",
self::g=>"Miscellaneous",
self::h=>"Place of Assembly",
self::i=>"Residencial",
self::j=>"Small/General Business",
self::k=>"Storage"
);


}

const l ="Baclaran";
const m ="Tambo";
const n="La Huerta";
const o ="Sto. Nino";
const p ="Vitalez";
const q ="Don Galo";
const r ="San Isidro";
const s ="Moonwalk";
const t ="San Antonio";
const u ="Don Bosco";
const v ="Marcelo Green";
const w ="Merville";
const x ="Sun Valley";
const y ="San Martin De Porres";
public function getBaranggay(){
return array(
self::l=>"Baclaran",
self::m=>"Tambo",
self::n=>"La Huerta",
self::o=>"Sto. Nino",
self::p=>"Vitalez",
self::q=>"Don Galo",
self::r=>"San Isidro",
self::s=>"Moonwalk",
self::t=>"San Antonio",
self::u=>"Don Bosco",
self::v=>"Marcelo Green",
self::w=>"Merville",
self::x=>"Sun Valley",
self::y=>"San Martin De Porres"
);


}




	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'establishment';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('type_of_establishment', 'length', 'max'=>22),
			array('building_owner', 'length', 'max'=>45),
			array('baranggay', 'length', 'max'=>20),
			array('establishment_name, address_street', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, type_of_establishment, establishment_name, building_owner, address_street, baranggay', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'clientContactPeople' => array(self::HAS_MANY, 'ClientContactPerson', 'establishment_id'),
			'inspections' => array(self::HAS_MANY, 'Inspection', 'establishment_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'type_of_establishment' => 'Type Of Establishment',
			'establishment_name' => 'Establishment Name',
			'building_owner' => 'Building Owner',
			'address_street' => 'Address Street',
			'baranggay' => 'Baranggay',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('type_of_establishment',$this->type_of_establishment,true);
		$criteria->compare('establishment_name',$this->establishment_name,true);
		$criteria->compare('building_owner',$this->building_owner,true);
		$criteria->compare('address_street',$this->address_street,true);
		$criteria->compare('baranggay',$this->baranggay,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}